package com.hwhhhh.graduationproject.controller;

import com.hwhhhh.graduationproject.controller.param.Lv1Req;
import com.hwhhhh.graduationproject.controller.param.Lv2Req;
import com.hwhhhh.graduationproject.utils.ResponseData;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description detail
 * Created by Hwhhhh on 2021/3/2 15:11
 */
@RestController
public class CommentController extends BaseController{
    /**
     * 根据教室id获取教室评论
     * @param id
     * @param page
     * @return
     */
    @GetMapping("/comments")
    public ResponseData getComments(@RequestParam("classroomId")int classroomId, @RequestParam("page") int page) {
        return new ResponseData(this.commentService.getNewLv1ByClassroomId(classroomId, page));
    }

    @PostMapping("/comments/lv1")
    public ResponseData makeCommentLv1(@RequestBody Lv1Req lv1Req) {
        Map<String, Integer> map = new HashMap<>();
        map.put("id", this.commentService.makeCommentLv1(lv1Req));
        return new ResponseData(map);
    }

    @DeleteMapping("/comments/lv1/{id}")
    public ResponseData deleteCommentLv1(@PathVariable("id") int id) {
        return new ResponseData();
    }

    @PostMapping("/comments/lv2")
    public ResponseData makeCommentLv2(@RequestBody Lv2Req lv2Req) {
        Map<String, Integer> map = new HashMap<>();
        map.put("id", this.commentService.makeCommentLv2(lv2Req));
        return new ResponseData(map);
    }

    @DeleteMapping("/comments/lv2/{id}")
    public ResponseData deleteCommentLv2(@PathVariable("id") int id) {
        return new ResponseData();
    }
}
